using Cysharp.Threading.Tasks;
using Framework.StateMechine;
using UnityEngine;

namespace Game.Hotfix
{
    public class HotfixReinstall : StateBase
    {
        private Game.Hotfix.Hotfix hotfix;
        
        public override async UniTask OnEnter(StateArgs _args)
        {
            Debug.Log("engine version so old, install new game client pls.");
            
            hotfix = stateMachine.owner as Game.Hotfix.Hotfix;
            await base.OnEnter(_args);

            await OpenWeb2Install();
        }
        
        // 打开下载网页，然后进程退出
        private async UniTask OpenWeb2Install()
        {
            Application.OpenURL("www.baidu.com");
            await UniTask.WaitForSeconds(2);
            QuitGame();
        }

        private void QuitGame()
        {
            Application.Quit();
        }
    }
}